﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Principal.master" AutoEventWireup="true" CodeFile="CategoriaDeMenu.aspx.cs" Inherits="CategoriaDeMenu" %>
<%@ OutputCache Duration="1" Location="none" %>

<%@ Register src="MenusDePagina/WebUserControlMenuAdministracion.ascx" tagname="WebUserControlMenuAdministracion" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">

    <uc1:WebUserControlMenuAdministracion ID="WebUserControlMenuAdministracion1" 
        runat="server" />

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h1>Categorias de menú</h1>
    <asp:Panel ID="Panel1" runat="server">
        <asp:Label ID="Label1" runat="server"></asp:Label>
    </asp:Panel>
    <div id="Contenedor">
    <asp:FormView ID="FormViewCategoriasDeMenu" runat="server" DataKeyNames="Codigo" 
        DataSourceID="ObjectDataSourceCategoriaDeMenu" DefaultMode="Insert" 
        HorizontalAlign="Center" 
        oniteminserted="FormViewCategoriasDeMenu_ItemInserted" Visible="False">
        <InsertItemTemplate>
            <table class="detalle">
                <thead>
                <tr>
                    <th colspan="2" align="center">Adicionar</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        Nombre:</td>
                    <td>
                        <asp:TextBox ID="NombreTextBox" runat="server" Text='<%# Bind("Nombre") %>' 
                            MaxLength="50" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorNombre" runat="server" 
                            ControlToValidate="NombreTextBox" 
                            ErrorMessage="El nombre de la categoría es obligatorio" 
                            ValidationGroup="Validadores">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="2">
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                            CommandName="Insert" Text="Insertar" ValidationGroup="Validadores" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                            CausesValidation="False" CommandName="Cancel" 
                            onclick="InsertCancelButton_Click" Text="Cancelar" />
                    </td>
                </tr>
                </tfoot>
            </table>
        </InsertItemTemplate>
    </asp:FormView>
    <br />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="Codigo" 
        DataSourceID="ObjectDataSourceCategoriaDeMenu" CellPadding="4" 
        ForeColor="#333333" GridLines="None" HorizontalAlign="Center" 
        CssClass="detalle">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Actualizar" ValidationGroup="Validadores1"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Cancelar"></asp:LinkButton>
                </EditItemTemplate>
                <HeaderTemplate>
                    <asp:LinkButton ID="LinkButtonAddNew" runat="server" 
                        onclick="LinkButtonAddNew_Click">Adicionar nuevo</asp:LinkButton>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Modificar"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Eliminar" 
                        onclientclick="javascript:return ConfirmDel(this);"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Codigo" HeaderText="Codigo" ReadOnly="True" 
                SortExpression="Codigo" />
            <asp:TemplateField HeaderText="Nombre" SortExpression="Nombre">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Nombre") %>' 
                        MaxLength="50"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="TextBox1" ErrorMessage="Campo Obligatorio" 
                        ValidationGroup="Validadores1"></asp:RequiredFieldValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Nombre") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <EmptyDataTemplate>
            No existen datos acerca de la consulta.
            <br />
            <br />
            <asp:LinkButton ID="LinkButtonAddNew" runat="server" 
                onclick="LinkButtonAddNew_Click">Adicionar nuevo</asp:LinkButton>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    </div>
    <asp:ObjectDataSource ID="ObjectDataSourceCategoriaDeMenu" runat="server" 
        DeleteMethod="eliminarCategoria" InsertMethod="crearCategoria" 
        SelectMethod="consultarCategoriasDeMenu" 
        TypeName="Libreria.SIG.Negocio.CategoriaDeMenuNegocio" 
        UpdateMethod="actualizarCategoria" 
        ondeleted="ObjectDataSourceCategoriaDeMenu_Deleted">
        <DeleteParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
            <asp:Parameter Direction="Output" Name="mensaje" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Codigo" Type="Int32" />
            <asp:Parameter Name="Nombre" Type="String" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="HiddenFieldCadenaDeConexion" 
                Name="cadenaDeConexion" PropertyName="Value" Type="String" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="Nombre" Type="String" />
            <asp:Parameter Name="cadenaDeConexion" Type="String" />
            <asp:Parameter Name="Codigo" Type="Int32" />
        </InsertParameters>
    </asp:ObjectDataSource>
    <asp:HiddenField ID="HiddenFieldCadenaDeConexion" runat="server" />
    
    </div>
</asp:Content>

